/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-11-06     SummerGift   first version
 * 2019-10-19     xuzhuoyi     add stm32f429-st-disco bsp
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <rtthread.h>
#include <board.h>
#include <dfs_fs.h>
#include <dfs_ramfs.h>
#include <dfs_romfs.h>

/* defined the LED1 pin: PG13 */
#define LED1_PIN    GET_PIN(G, 13)

rt_uint8_t fs_blocks[8*1024];

int main(void)
{
    int count = 1;
    /* set LED1 pin mode to output */
    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);

    int ret;
    if((ret=dfs_mount(NULL,"/","rom",0,&romfs_root))==0)
    {
        printf("mount ok to / use rom\r\n");
    }
    else
    {
        printf("mount error to / use rom,ret=%d\r\n",ret);
    }
    
    struct dfs_ramfs *ramdisk = dfs_ramfs_create(fs_blocks,sizeof(fs_blocks));
    dfs_mount(NULL,"/ram","ram",O_RDWR,ramdisk);
    
    while (count++)
    {
        rt_pin_write(LED1_PIN, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED1_PIN, PIN_LOW);
        rt_thread_mdelay(500);
    }

    return RT_EOK;
}
